//
//  ZYNewThreeGoodStrongCell.m
//  优学荟管理系统
//
//  Created by ちょうかんこん on 2018/1/11.
//  Copyright © 2018年 星道三好. All rights reserved.
//

#import "ZYNewThreeGoodStrongCell.h"
#import "ZYNewThreeGoodStrongModel.h"
@implementation ZYNewThreeGoodStrongCell {
    NSString *ID;
    NSString *uid;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setUpSuperView];
    }
    
    
    
    return self;
    
}

- (void)assignByZYNewThreeGoodStrongModel:(ZYNewThreeGoodStrongModel *)model{
    
    self.nameLabel.text = [NSString stringWithFormat:@"%@",model.name];
    self.timeLabel.text = [NSString stringWithFormat:@"上课老师：%@",model.petname];
    
    self.circleProgressView.percent = [model.percent floatValue];
    
    float mm = [model.percent floatValue] * 100;
    self.circleProgressView.centerLabel.text = [NSString stringWithFormat:@"%.f%@",mm,@"%"];
    
    ID = model.ID;
    uid = model.uid;
    /// 添加长按删除
    UILongPressGestureRecognizer * longPressGesture =[[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(cellLongPress:)];
    longPressGesture.minimumPressDuration = 1.0f;//设置长按 时间
    [self addGestureRecognizer:longPressGesture];
    
}


#pragma mark - 长按手势触发
- (void)cellLongPress:(UITapGestureRecognizer *)tap {
    //    deleteImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pop_deleted_default_handle_course"]];
    //    [deleteImage setUserInteractionEnabled:YES];
    //    [self.contentView addSubview:deleteImage];
    //
    //    [deleteImage mas_makeConstraints:^(MASConstraintMaker *make) {
    //        make.top.right.equalTo(self.contentView);
    //    }];
    //
    //    UITapGestureRecognizer *tapCilk = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(deleteStudent:)];
    //    [deleteImage addGestureRecognizer:tapCilk];
    
    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"是否删除选中的学生" preferredStyle:(UIAlertControllerStyleActionSheet)];
    UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        
        self.ClickDelete ? self.ClickDelete(ID,uid) : nil;
    }];
    
    UIAlertAction *actionTwo = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:^(UIAlertAction * _Nonnull action) {
        
        //        if (_ReloadData) {
        //            _ReloadData();
        //            [deleteImage removeFromSuperview];
        //        }
    }];
    
    [alertVC addAction:actionOne];
    [alertVC addAction:actionTwo];
    
    [[[AppDelegate shareAppDelegate] getCurrentUIVC] presentViewController:alertVC animated:YES completion:nil];
}




- (void)setUpSuperView{
    
    
    self.nameLabel = [UILabel new];
    self.nameLabel.font = [UIFont systemFontOfSize:16];
    self.nameLabel.textColor = ColorRGB(51, 51, 51);
    [self.contentView addSubview:self.nameLabel];
    
    
    self.couseLabel = [UILabel new];
    self.couseLabel.font = [UIFont systemFontOfSize:14];
    self.couseLabel.textColor = ColorRGB(102,102,102);
    self.couseLabel.numberOfLines = 0;
    [self.contentView addSubview:self.couseLabel];
    
    self.timeLabel = [UILabel new];
    self.timeLabel.font = [UIFont systemFontOfSize:12];
    self.timeLabel.textColor = ColorRGB(102,102,102);
    [self.contentView addSubview:self.timeLabel];
    
    
    
    
    
    self.circleProgressView = [[CircleProgressView alloc]initWithFrame:CGRectMake(kScreenWidth - (kScreenWidth *86/750 + kScreenWidth *30/750) - 10 , kScreenHeight *60/1334, kScreenWidth *86/750, kScreenWidth *86/750)];
    
    
    self.circleProgressView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.circleProgressView];
    
    self.nameLabel.text = @"北京上海";
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kScreenWidth *33/750);
        make.top.offset(kScreenHeight *30/1334);
        make.right.equalTo(self).offset(-kScreenWidth *86/750);
    }];
    
    
    
    [self.couseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel);
        make.right.equalTo(self).offset(-kScreenWidth *86/750);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(0);
    }];
    
    
    [self.circleProgressView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-kScreenWidth *30/750);
        make.centerY.equalTo(self.couseLabel);
        make.width.height.offset(kScreenWidth *86/750);
    }];
    
    UILabel *label = [UILabel new];
    label.font = [UIFont systemFontOfSize:11];
    label.textColor = ColorRGB(102,102,102);
    label.textAlignment = NSTextAlignmentCenter;
    label.text = @"评价率";
    [self.contentView addSubview:label];
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-kScreenWidth *30/750);
        make.top.equalTo(self.circleProgressView.mas_bottom).offset(3);
        make.width.equalTo(self.circleProgressView);
    }];
    
    
    self.timeLabel.text = @"布置时间：2012.3.11";
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.couseLabel);
        make.top.equalTo(self.couseLabel.mas_bottom).offset(kScreenHeight *30/1334);
    }];
    
    
    
    
    
    
    
    
    UILabel *lineLabel = [UILabel new];
    lineLabel.backgroundColor = ColorRGB(247, 245, 245);
    [self.contentView addSubview:lineLabel];
    
    
    [lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.top.equalTo(self.timeLabel.mas_bottom).offset(16);
        make.width.offset(kScreenWidth);
        make.height.offset(kScreenHeight *30/1334);
    }];
    
    
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(0);
        make.bottom.mas_equalTo(lineLabel).offset(0);
    }];
    
    
}


@end
